<?php

use common\widgets\Alert;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;

$this->title = $installed ? '数据库已安装' : '请安装数据库';
?>

<style>
    .middle {
        position: absolute;
        top: 40%;
        left: 50%;
        margin-left: -230px;
        transform: translateY(-50%);
        width: 460px;
    }
</style>

<?php if ($installed): ?>

<div class="middle panel panel-default text-center">
    <div class="panel-heading">
        <h2>您的数据库已安装成功</h2>
    </div>
    <div class="panel-body text-left">
        <!-- <?= Html::a('删除整个数据库', ['install/drop'], ['class' => 'btn btn-default']) ?> -->

        <div style="margin:15px 0 20px 0;" class="text-center">
            <?= Html::a('更新数据库', ['install/update'], ['class' => 'btn btn-primary']) ?>
        </div>
        
        <?php if (Yii::$app->user->isGuest) { ?>
            <h6 class="alert alert-success">
                请使用登录系统.
                <?= Html::a('登录系统', ['default/login'], ['class' => 'btn btn-success pull-right', 'style' => "margin-top:-10px;"]) ?>
            </h6>
        <?php } ?>
    </div>
</div>

<?php else: ?>

<div class="middle panel panel-default text-center">
    <div class="panel-heading">
        <h2>安装数据库</h2>
    </div>
    <div class="panel-body">
        <h5 class="text-muted">请确认<code>[/config/db.php]</code>中的数据库配置正确</h5>
        <form class="form" action="<?= Url::to(['install/run-installation']) ?>" method="post">
            <input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
            <div class="form-group text-center">
                <button type="submit" class="btn btn-default">初始化安装</button>
            </div>
        </form>
    </div>
</div>

<?php endif; ?>